package com.wangan.wanganpush.xml;

import com.wangan.wanganpush.model.UserOrderInfo;
import com.wangan.wanganpush.utils.AppConstants;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单信息xml拼接
 */
public class UserOrderInfoXml {


    public static String parseXml(List<UserOrderInfo> urList,String messageCode) {

        if (urList == null || urList.size() == 0) return null;
        try {
            StringBuffer sb = new StringBuffer();
            sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>  <MESSAGE>");
            sb.append("<DATASET name=\"WA_COMMON_010000\">  <DATA>");
            sb.append("<ITEM key=\"H010001\" val=\"" + AppConstants.applicationCoding + "\"/>");
            sb.append("<ITEM key=\"I010014\" val=\"" + messageCode + "\"/>");
            sb.append("<ITEM key=\"I010031\" val=\"" + "VEHICLEBOOK" + "\"/>");
            sb.append("<ITEM key=\"I010013\" val=\"" + 3 + "\"/>");
            sb.append("</DATA> </DATASET> ");

            sb.append("<DATASET name=\"WA_COMMON_010022\">");

            for (int i = 0; i < urList.size(); i++) {
                UserOrderInfo u = urList.get(i);
                sb.append("<DATA>");
                if (u.getUserAccount() != null) {
                    sb.append("<ITEM key=\"B040002\" val=\"" + u.getUserAccount() + "\"/>");
                }

                if (u.getUserId() != null) {
                    sb.append("<ITEM key=\"B040003\" val=\"" + u.getUserId() + "\"/>");
                }

                if (u.getUserName() != null) {
                    sb.append("<ITEM key=\"H230002\" val=\"" + u.getUserName() + "\"/>");
                }

                if (u.getMobilePhone() != null) {
                    sb.append("<ITEM key=\"H230003\" val=\"" + u.getMobilePhone() + "\"/>");
                }

                if (u.getTel() != null) {
                    sb.append("<ITEM key=\"H230004\" val=\"" + u.getTel() + "\"/>");
                }

                if (u.getEmail() != null) {
                    sb.append("<ITEM key=\"H230005\" val=\"" + u.getEmail() + "\"/>");
                }

                if (u.getAddress() != null) {
                    sb.append("<ITEM key=\"H230006\" val=\"" + u.getAddress() + "\"/>");
                }

                if (u.getReceiverName() != null) {
                    sb.append("<ITEM key=\"B020013\" val=\"" + u.getReceiverName() + "\"/>");
                }

                if (u.getReceiverPhone() != null) {
                    sb.append("<ITEM key=\"B020014\" val=\"" + u.getReceiverPhone() + "\"/>");
                }

                if (u.getReceiverAddress() != null) {
                    sb.append("<ITEM key=\"B020015\" val=\"" + u.getReceiverAddress() + "\"/>");
                }

                if (u.getOrderNo() != null) {
                    sb.append("<ITEM key=\"H090001\" val=\"" + u.getOrderNo() + "\"/>");
                }

                if (u.getCreateOrderTime() != null) {
                    sb.append("<ITEM key=\"H230007\" val=\"" + u.getCreateOrderTime() + "\"/>");
                }

                if (u.getOrderContent() != null) {
                    sb.append("<ITEM key=\"H230008\" val=\"" + u.getOrderContent() + "\"/>");
                }

                if (u.getOrderContentZip() != null) {
                    sb.append("<ITEM key=\"H230009\" val=\"" + u.getOrderContentZip() + "\"/>");
                }

                if (u.getCreateOrderPhone() != null) {
                    sb.append("<ITEM key=\"B020005\" val=\"" + u.getCreateOrderPhone() + "\"/>");
                }

                if (u.getCreateOrderClientIp() != null) {
                    sb.append("<ITEM key=\"F020004\" val=\"" + u.getCreateOrderClientIp() + "\"/>");
                }

                if (u.getCreateOrderClientPort() != null) {
                    sb.append("<ITEM key=\"F020006\" val=\"" + u.getCreateOrderClientPort() + "\"/>");
                }

                if (u.getCreateOrderClientMac() != null) {
                    sb.append("<ITEM key=\"C040002\" val=\"" + u.getCreateOrderClientMac() + "\"/>");
                }

                if (u.getCreateOrderClientImsi() != null) {
                    sb.append("<ITEM key=\"B020007\" val=\"" + u.getCreateOrderClientImsi() + "\"/>");
                }

                if (u.getCreateOrderClientImei() != null) {
                    sb.append("<ITEM key=\"C050001\" val=\"" + u.getCreateOrderClientImei() + "\"/>");
                }

                if (u.getCreateOrderClientTE() != null) {
                    sb.append("<ITEM key=\"C040003\" val=\"" + u.getCreateOrderClientTE() + "\"/>");
                }

                if (u.getCreateOrderPhoneType() != null) {
                    sb.append("<ITEM key=\"C020011\" val=\"" + u.getCreateOrderPhoneType() + "\"/>");
                }

                if (u.getVehicleType() != null) {
                    sb.append("<ITEM key=\"H230011\" val=\"" + u.getVehicleType() + "\"/>");
                }

                if (u.getVehicleTypeCode() != null) {
                    sb.append("<ITEM key=\"H230012\" val=\"" + u.getVehicleTypeCode() + "\"/>");
                }

                if (u.getVehicleTypeDec() != null) {
                    sb.append("<ITEM key=\"H230013\" val=\"" + u.getVehicleTypeDec() + "\"/>");
                }

                if (u.getPassengerNum() != null) {
                    sb.append("<ITEM key=\"H230014\" val=\"" + u.getPassengerNum() + "\"/>");
                }

                if (u.getAppointmentTimeUp() != null) {
                    sb.append("<ITEM key=\"H230015\" val=\"" + u.getAppointmentTimeUp() + "\"/>");
                }

                if (u.getAppointMentAddressUp() != null) {
                    sb.append("<ITEM key=\"H230016\" val=\"" + u.getAppointMentAddressUp() + "\"/>");
                }

                if (u.getAppointMentLongitudeUp() != null) {
                    sb.append("<ITEM key=\"H230017\" val=\"" + u.getAppointMentLongitudeUp() + "\"/>");
                }

                if (u.getAppointMentLatitudeUp() != null) {
                    sb.append("<ITEM key=\"H230018\" val=\"" + u.getAppointMentLatitudeUp() + "\"/>");
                }

                if (u.getAppointMentAddressDown() != null) {
                    sb.append("<ITEM key=\"H230019\" val=\"" + u.getAppointMentAddressDown() + "\"/>");
                }

                if (u.getAppointMentLongitudeDown() != null) {
                    sb.append("<ITEM key=\"H230020\" val=\"" + u.getAppointMentLongitudeDown() + "\"/>");
                }

                if (u.getAppointMentLatitudeDown() != null) {
                    sb.append("<ITEM key=\"H230021\" val=\"" + u.getAppointMentLatitudeDown() + "\"/>");
                }

                if (u.getAppointMentCityUp() != null) {
                    sb.append("<ITEM key=\"H230022\" val=\"" + u.getAppointMentCityUp() + "\"/>");
                }

                if (u.getAppointMentStoreUp() != null) {
                    sb.append("<ITEM key=\"H230023\" val=\"" + u.getAppointMentStoreUp() + "\"/>");
                }

                if (u.getAppointMentStoreAddressUp() != null) {
                    sb.append("<ITEM key=\"H230024\" val=\"" + u.getAppointMentStoreAddressUp() + "\"/>");
                }

                if (u.getAppointMentTimeGet() != null) {
                    sb.append("<ITEM key=\"H230025\" val=\"" + u.getAppointMentTimeGet() + "\"/>");
                }

                if (u.getAppointMentCityDown() != null) {
                    sb.append("<ITEM key=\"H230026\" val=\"" + u.getAppointMentCityDown() + "\"/>");
                }

                if (u.getAppointMentStoreDown() != null) {
                    sb.append("<ITEM key=\"H230027\" val=\"" + u.getAppointMentStoreDown() + "\"/>");
                }

                if (u.getAppointMentStoreAddressDown() != null) {
                    sb.append("<ITEM key=\"H230028\" val=\"" + u.getAppointMentStoreAddressDown() + "\"/>");
                }

                if (u.getAppointMentTimeDown() != null) {
                    sb.append("<ITEM key=\"H230029\" val=\"" + u.getAppointMentTimeDown() + "\"/>");
                }

                if (u.getAppointmentPrice() != null) {
                    sb.append("<ITEM key=\"H230030\" val=\"" + u.getAppointmentPrice() + "\"/>");
                }

                if (u.getStartAirport() != null) {
                    sb.append("<ITEM key=\"F010005\" val=\"" + u.getStartAirport() + "\"/>");
                }

                if (u.getArriveAirport() != null) {
                    sb.append("<ITEM key=\"F010006\" val=\"" + u.getArriveAirport() + "\"/>");
                }

                if (u.getFlightOrTrainNo() != null) {
                    sb.append("<ITEM key=\"H090002\" val=\"" + u.getFlightOrTrainNo() + "\"/>");
                }

                if (u.getEto() != null) {
                    sb.append("<ITEM key=\"H010015\" val=\"" + u.getEto() + "\"/>");
                }

                if (u.getEta() != null) {
                    sb.append("<ITEM key=\"H010016\" val=\"" + u.getEta() + "\"/>");
                }

                if (u.getOrderAddress() != null) {
                    sb.append("<ITEM key=\"H230031\" val=\"" + u.getOrderAddress() + "\"/>");
                }

                if (u.getBuyerLongitude() != null) {
                    sb.append("<ITEM key=\"H230032\" val=\"" + u.getBuyerLongitude() + "\"/>");
                }

                if (u.getBuyerLatitude() != null) {
                    sb.append("<ITEM key=\"H230033\" val=\"" + u.getBuyerLatitude() + "\"/>");
                }

                if (u.getIsAnswer() != null) {
                    sb.append("<ITEM key=\"H230034\" val=\"" + u.getIsAnswer() + "\"/>");
                }

                if (u.getAcceptOrderTime() != null) {
                    sb.append("<ITEM key=\"H230035\" val=\"" + u.getAcceptOrderTime() + "\"/>");
                }

                if (u.getAcceptOrderAddress() != null) {
                    sb.append("<ITEM key=\"H230036\" val=\"" + u.getAcceptOrderAddress() + "\"/>");
                }

                if (u.getAcceptOrderLongitude() != null) {
                    sb.append("<ITEM key=\"H230037\" val=\"" + u.getAcceptOrderLongitude() + "\"/>");
                }

                if (u.getAcceptOrderLatitude() != null) {
                    sb.append("<ITEM key=\"H230038\" val=\"" + u.getAcceptOrderLatitude() + "\"/>");
                }

                if (u.getVehicleId() != null) {
                    sb.append("<ITEM key=\"C030009\" val=\"" + u.getVehicleId() + "\"/>");
                }

                if (u.getVehicleInfo() != null) {
                    sb.append("<ITEM key=\"C030015\" val=\"" + u.getVehicleInfo() + "\"/>");
                }

                if (u.getCompanyName() != null) {
                    sb.append("<ITEM key=\"E010002\" val=\"" + u.getCompanyName() + "\"/>");
                }

                if (u.getDriverAccount() != null) {
                    sb.append("<ITEM key=\"H230039\" val=\"" + u.getDriverAccount() + "\"/>");
                }

                if (u.getDriverUserId() != null) {
                    sb.append("<ITEM key=\"H230040\" val=\"" + u.getDriverUserId() + "\"/>");
                }

                if (u.getDriverName() != null) {
                    sb.append("<ITEM key=\"H230041\" val=\"" + u.getDriverName() + "\"/>");
                }

                if (u.getDriverIdType() != null) {
                    sb.append("<ITEM key=\"H230042\" val=\"" + u.getDriverIdType() + "\"/>");
                }

                if (u.getDriverIdNumber() != null) {
                    sb.append("<ITEM key=\"H230043\" val=\"" + u.getDriverIdNumber() + "\"/>");
                }

                if (u.getDriverPhoneNumber() != null) {
                    sb.append("<ITEM key=\"H230044\" val=\"" + u.getDriverPhoneNumber() + "\"/>");
                }

                if (u.getRelationOrderNo() != null) {
                    sb.append("<ITEM key=\"H230064\" val=\"" + u.getRelationOrderNo() + "\"/>");
                }

                if (u.getOnCarTime() != null) {
                    sb.append("<ITEM key=\"H230045\" val=\"" + u.getOnCarTime() + "\"/>");
                }

                if (u.getOnCarAddress() != null) {
                    sb.append("<ITEM key=\"F010014\" val=\"" + u.getOnCarAddress() + "\"/>");
                }

                if (u.getOnCarLongitude() != null) {
                    sb.append("<ITEM key=\"F010010\" val=\"" + u.getOnCarLongitude() + "\"/>");
                }

                if (u.getOnCarLatitude() != null) {
                    sb.append("<ITEM key=\"F010011\" val=\"" + u.getOnCarLatitude() + "\"/>");
                }

                if (u.getDownCarTime() != null) {
                    sb.append("<ITEM key=\"H230046\" val=\"" + u.getDownCarTime() + "\"/>");
                }

                if (u.getDownCarAddress() != null) {
                    sb.append("<ITEM key=\"F010015\" val=\"" + u.getDownCarAddress() + "\"/>");
                }

                if (u.getDownCarLongitude() != null) {
                    sb.append("<ITEM key=\"F010012\" val=\"" + u.getDownCarLongitude() + "\"/>");
                }

                if (u.getDownCarLatitude() != null) {
                    sb.append("<ITEM key=\"F010013\" val=\"" + u.getDownCarLatitude() + "\"/>");
                }

                if (u.getGoCarCity() != null) {
                    sb.append("<ITEM key=\"H230047\" val=\"" + u.getGoCarCity() + "\"/>");
                }

                if (u.getGoCarStore() != null) {
                    sb.append("<ITEM key=\"H230048\" val=\"" + u.getGoCarStore() + "\"/>");
                }

                if (u.getGoCarStoreAddress() != null) {
                    sb.append("<ITEM key=\"H230049\" val=\"" + u.getGoCarStoreAddress() + "\"/>");
                }

                if (u.getCollectionTime() != null) {
                    sb.append("<ITEM key=\"H230050\" val=\"" + u.getCollectionTime() + "\"/>");
                }

                if (u.getGetOutCity() != null) {
                    sb.append("<ITEM key=\"H230051\" val=\"" + u.getGetOutCity() + "\"/>");
                }

                if (u.getReturnCarStore() != null) {
                    sb.append("<ITEM key=\"H230052\" val=\"" + u.getReturnCarStore() + "\"/>");
                }

                if (u.getReturnCarStoreAddress() != null) {
                    sb.append("<ITEM key=\"H230053\" val=\"" + u.getReturnCarStoreAddress() + "\"/>");
                }

                if (u.getReturnCarTime() != null) {
                    sb.append("<ITEM key=\"H230054\" val=\"" + u.getReturnCarTime() + "\"/>");
                }

                if (u.getFactOrderPrice() != null) {
                    sb.append("<ITEM key=\"H230056\" val=\"" + u.getFactOrderPrice() + "\"/>");
                }

                if (u.getBranchingProgram() != null) {
                    sb.append("<ITEM key=\"H230055\" val=\"" + u.getBranchingProgram() + "\"/>");
                }

                if (u.getPresentTime() != null) {
                    sb.append("<ITEM key=\"H230010\" val=\"" + u.getPresentTime() + "\"/>");
                }

                if (u.getActionType() != null) {
                    sb.append("<ITEM key=\"H010003\" val=\"" + u.getActionType() + "\"/>");
                }

                if (u.getCityCode() != null) {
                    sb.append("<ITEM key=\"F010022\" val=\"" + u.getCityCode() + "\"/>");
                }

                sb.append("</DATA>");

            }

            sb.append("</DATASET>");
            sb.append("</MESSAGE>");

            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }


    }


}
